import { IPSDEField } from '../defield/ipsdefield';
import { IPSDEDQFieldCondition } from './ipsdedqfield-condition';
import { IPSDEDQJoin } from './ipsdedqjoin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEDQFieldConditionImpl extends PSModelObjectImpl implements IPSDEDQFieldCondition {
  get codeName(): string {
    return this.M.codeName;
  }

  get condOp(): string {
    return this.M.condOp;
  }

  get condType(): 'GROUP' | 'SINGLE' | 'CUSTOM' | 'PREDEFINED' {
    return this.M.condType;
  }

  get condValue(): string {
    return this.M.condValue;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get fieldName(): string {
    return this.M.fieldName;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdefield: IPSDEField | null = null;

  getPSDEField(): IPSDEField | null {
    if (this.psdefield != null) return this.psdefield;
    const value = this.M.getPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdedqjoin = this.getParentPSModelObject('dataentity.ds.IPSDEDQJoin') as IPSDEDQJoin;
    if (ipsdedqjoin != null) {
      this.psdefield = ipsdedqjoin.getJoinPSDataEntityMust().findPSDEField(value);
    }
    return this.psdefield;
  }

  get psDEField(): IPSDEField | null {
    return this.getPSDEField();
  }

  getPSDEFieldMust(): IPSDEField {
    const value = this.getPSDEField();
    if (value == null) {
      throw new Error('未指定属性对象');
    }
    return value;
  }

  get psVARTypeId(): string {
    return this.M.getPSVARTypeId;
  }

  getPSVARTypeId(): string {
    return this.M.getPSVARTypeId;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get valueFunc(): string {
    return this.M.valueFunc;
  }

  get valueFuncTag(): string {
    return this.M.valueFuncTag;
  }

  get valueFuncTag2(): string {
    return this.M.valueFuncTag2;
  }

  get ignoreEmpty(): boolean {
    return this.M.ignoreEmpty != null ? this.M.ignoreEmpty : false;
  }

  get cls(): string {
    return 'PSDEDQFieldConditionImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.ds.IPSDEDQFieldCondition') return true;
    return super.instanceof(cls);
  }
}
